// 페이스북 API

document.write('<div id="fb-root"></div>');

var _facebook_status;
	
window.fbAsyncInit = function() {
	FB.init({
		appId      : '401165613279411', // App ID
		channelUrl : '//www.golfinsns.com/channel.html', // Channel File
		status     : true, // check login status
		cookie     : true, // enable cookies to allow the server to access the session
		xfbml      : true  // parse XFBML
		, oauth: true
	});
	    
	function updateStatus(response) {
		//var button = document.getElementById('fb-auth');
		_facebook_status = _facebook_status || {};
	
		_facebook_status["상태"] = response.status;
		if (response.status === 'connected') {
			// the user is logged in and has authenticated your
			// app, and response.authResponse supplies
			// the user's ID, a valid access token, a signed
			// request, and the time the access token 
			// and signed request each expire
			var uid = response.authResponse.userID;
			var accessToken = response.authResponse.accessToken;
	
			_facebook_status["아이디"] = uid;
			_facebook_status["액서스키"] = accessToken;
	
			FB.api('/me', function(response) {
				_facebook_status["me"] = {
					"이름": response.name
					, "이미지": "https://graph.facebook.com/" + response.id + "/picture?type=large"
				}
	
				$(document).trigger("FBME");
			});
		} else if (response.status === 'not_authorized') {
			// the user is logged in to Facebook, 
			// but has not authenticated your app
		} else {
			// the user isn't logged in to Facebook.
		}
		
		$(document).trigger("updateFBStatus");
	  }
	
	  // run once with current status and whenever the status changes
	  FB.getLoginStatus(updateStatus);
	  FB.Event.subscribe('auth.statusChange', updateStatus);

	
};
 	  
  $.ajax({
  	url: "//connect.facebook.net/en_US/all.js"
  	, dataType: "script"
  	, success: function(){
  		
  	}
});